package com.ricervcvcer.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ricervcvcer.user.entity.SysRight;
import com.ricervcvcer.user.entity.SysRoleRight;
import com.ricervcvcer.user.mapper.SysRightMapper;
import com.ricervcvcer.user.mapper.SysRoleRightMapper;
import com.ricervcvcer.user.service.ISysRoleRightService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author moge
 * @since 2022-01-10
 */
@Service
public class SysRoleRightServiceImpl extends ServiceImpl<SysRoleRightMapper, SysRoleRight> implements ISysRoleRightService {

    @Resource
    SysRightMapper rightMapper;

    @Override
    public List<SysRoleRight> sellist(QueryWrapper qw) {
        List<SysRoleRight> list = this.list(qw);
        return list.stream().filter(item -> {
            QueryWrapper<SysRight> queryWrapper = new QueryWrapper();
            queryWrapper.eq("right_parent", item.getRfRightCode());
            SysRight sysRight = rightMapper.selectById(item.getRfRightCode());
            if (sysRight.getRightType().equals("Folder")) {
                return false;
            }
            return true;
        }).collect(Collectors.toList());
    }
}
